home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!austern
- From: "Eugene Radchenko" <eugene@qsar.chem.msu.su>
- Newsgroups: comp.std.c++
- Subject: More on the operations on the entire container
- Date: 17 Jan 1996 12:21:55 PST
- Organization: Lab. of Org.Synth., MSU
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <AFyED_m0h3@qsar.chem.msu.su>
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: Wed, 17 Jan 1996 13:47:24 +0300 (MSK)
- X-Mailer: dMail [Demos Mail for DOS v1.23]
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMP1adky4NqrwXLNJAQGrAAIAknlh0cL24IH/hR05SwFskqyRs/BsAw/p
- xxJLM3ms7zFt/o+OV4JI4q6EsPEBmu7N/rMZN4sG4qoXogj6QYoNsg==
- =kMyz
- Originator: austern@isolde.mti.sgi.com
-
- Hi!
- Operations on the whole container are (as the threads flashing here
- sometimes show) the most common kind of range operations in a program using
- the STL. Hence, it is generally felt that the current idiom for this
- Iterator i = find(c.begin(), c.end(), x);
- is verbose, cumbersome and error-prone. However, no solution (fitting into
- the split container/algorithm paradigm) has been proposed yet.
- I think this can do the trick:
- template <class Iterator> struct range : public pair<Iterator, Iterator> {
- range(Iterator first, Iterator last)
- : pair<Iterator, Iterator>(first, last) {}
- };
- template <...> class vector {
- //....
- range<iterator> all() { return range(begin(), end()); }
- range<const_iterator> all() const { return range(begin(), end()); }
- };
- Also, the library would provide the 'range' version of all functions, e.g.
- template<class Iterator, class T> Iterator find(range<Iterator> r, T x);
- simply inlining to find(r.first, r.second, x).
-
- (If the conversions were allowed in the template deduction, it would be
- even simpler with
- operator range<iterator>()
- in vector).
-
- So, what do you think? Genie
-
- --
- --------------------------------------------------------------------
- Eugene V. Radchenko Research associate, Computer Chemistry
- E-mail: eugene@qsar.chem.msu.su Fax: +7-(095)939-0290
- Ordinary mail: Chair of Organic Chemistry, Department of Chemistry,
- Moscow State University, 119899 Moscow, Russia
- ***************** Disappearances are deceptive *******************
- ---
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
- is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
-